package cn.iocoder.yudao.module.member.dal.mysql.scorerecord;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.scorerecord.vo.ScoreRecordExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.scorerecord.vo.ScoreRecordPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scorerecord.ScoreRecordDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 用户积分兑换 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ScoreRecordMapper extends BaseMapperX<ScoreRecordDO> {

    default PageResult<ScoreRecordDO> selectPage(ScoreRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ScoreRecordDO>()
                .eqIfPresent(ScoreRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ScoreRecordDO::getScoreTypeId, reqVO.getScoreTypeId())
                .eqIfPresent(ScoreRecordDO::getScore, reqVO.getScore())
                .betweenIfPresent(ScoreRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScoreRecordDO::getId));
    }

    default List<ScoreRecordDO> selectList(ScoreRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ScoreRecordDO>()
                .eqIfPresent(ScoreRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ScoreRecordDO::getScoreTypeId, reqVO.getScoreTypeId())
                .eqIfPresent(ScoreRecordDO::getScore, reqVO.getScore())
                .betweenIfPresent(ScoreRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScoreRecordDO::getId));
    }

}
